package 二叉树相关问题.中度题;

public class 删除给定值的叶子结点 {
    public TreeNode removeLeafNodes(TreeNode root, int target) {
         if (root==null)
             return null;
        TreeNode left = removeLeafNodes(root.left, target);
        TreeNode right = removeLeafNodes(root.right, target);
        root.left=left;
        root.right=right;
        if (root.left==null && root.right==null && root.val==target){
            return null;
        }
        return root;
    }
}
